from random import randint
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

# 初始化driver
driver = webdriver.Chrome()

# 打开百度
driver.get("https://www.baidu.com/")

# 设置隐式等待
driver.implicitly_wait(15)

# 输入文本内容
driver.find_element(By.NAME,"wd").send_keys("selenium")

# 点击百度一下按钮
driver.find_element(By.ID,"su").click()
sleep(5)

# 操作滚动条
win1 = "window.scrollBy(0,1000)" # Y轴向下1000像素
win2 = "window.scrollBy(0,-500)" # Y轴向上500像素
win3 = "window.scrollBy(500,0)" # X轴向右500像素
win4 = "window.scrollBy(-500,0)" # X轴向左500像素

driver.execute_script(win1) # 执行Y轴向下1000
sleep(5)
driver.execute_script(win2) # 执行Y轴向上500
sleep(5)
driver.execute_script(win3) # 执行X轴向右500
sleep(5)
driver.execute_script(win4) # 执行X轴向左500
sleep(3) # alt+enter，选择导入


